
package ch.hearc.meteo.imp.afficheur.real.vue.atome;

import java.awt.Color;
import java.util.List;

import ch.hearc.meteo.imp.afficheur.real.moo.StationMeteoElement;
import ch.hearc.meteo.imp.afficheur.simulateur.vue.atome.MathTools;
import ch.hearc.meteo.spec.meteo.listener.event.MeteoEvent;

public class JPanelStatsPression extends JPanelStats
	{

	public JPanelStatsPression(String title, List<StationMeteoElement> stationMeteoElements, JPanelGraph panelGraph)
		{
		super(title, stationMeteoElements, panelGraph);
		}

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/
	@Override
	public void refresh()
		{
		//Tools
		Float maxValue = 0.0f;
		Float minValue = 0.0f;
		Float moyValue = 0.0f;
		int cmpt = 0;
		synchronized (stationMeteoElements)
			{
			for(StationMeteoElement stationMeteoElement:stationMeteoElements)
				{
				synchronized (stationMeteoElement.getListPression())
					{
					for(MeteoEvent event:stationMeteoElement.getListPression())
						{
						if (cmpt == 0 || maxValue < event.getValue())
							{
							maxValue = event.getValue();
							maxColor = stationMeteoElement.getGraphColor();
							}
						if (cmpt == 0 || minValue > event.getValue())
							{
							minValue = event.getValue();
							minColor = stationMeteoElement.getGraphColor();
							}
						moyValue += event.getValue();
						cmpt++;
						}
					}
				}

			}

		if (cmpt > 0)
			{
			setMax(MathTools.arrondir(maxValue).toString());
			setMin(MathTools.arrondir(minValue).toString());
			moyValue /= cmpt;
			setMoy(MathTools.arrondir(moyValue).toString());
			}
		else
			{
			setMax(NO_VALUE);
			setMin(NO_VALUE);
			setMoy(NO_VALUE);
			maxColor = Color.WHITE;
			minColor = Color.WHITE;
			}

		}
	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/
	}
